package net.lainiao.zhihu.control.front;

import net.lainiao.zhihu.common.MyPage;
import net.lainiao.zhihu.model.Zhihuhuati;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import net.lainiao.zhihu.service.ZhihuhuatiService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Administrator on 2016/1/18.
 */
@Controller
@RequestMapping(value="/front/reci")
public class ReciControl {
    @Resource
    private ZhihuhuatiService zhihuhuatiService;
    @RequestMapping(method= RequestMethod.GET)
    public String index(ModelMap modelMap,HttpServletRequest request){
        String pageindex=request.getParameter("pageindex");
        if(StringUtils.isEmpty(pageindex)){
            pageindex="1";
        }
        int pageindexint=Integer.parseInt(pageindex);
        MyPage myPage=new MyPage();
        myPage.setCurrentPage(pageindexint);
        myPage.setPageSize(20);
        List<Zhihuhuati> list=zhihuhuatiService.getPage(myPage);
        modelMap.put("list",list);
        modelMap.put("total", myPage.getTotalPage());
        return "front/duanzi";
    }
}
